<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Psych::Handler - psych: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="../Object.html">Object</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-i-alias">#alias</a>
    <li ><a href="#method-i-empty">#empty</a>
    <li ><a href="#method-i-end_document">#end_document</a>
    <li ><a href="#method-i-end_mapping">#end_mapping</a>
    <li ><a href="#method-i-end_sequence">#end_sequence</a>
    <li ><a href="#method-i-end_stream">#end_stream</a>
    <li ><a href="#method-i-event_location">#event_location</a>
    <li ><a href="#method-i-scalar">#scalar</a>
    <li ><a href="#method-i-start_document">#start_document</a>
    <li ><a href="#method-i-start_mapping">#start_mapping</a>
    <li ><a href="#method-i-start_sequence">#start_sequence</a>
    <li ><a href="#method-i-start_stream">#start_stream</a>
    <li ><a href="#method-i-streaming-3F">#streaming?</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Psych::Handler">
    <h1 id="class-Psych::Handler" class="class">
      class Psych::Handler
    </h1>

    <section class="description">
    
<p><a href="Handler.html"><code>Psych::Handler</code></a> is an abstract base class that defines the events used when dealing with <a href="Parser.html"><code>Psych::Parser</code></a>.  Clients who want to use <a href="Parser.html"><code>Psych::Parser</code></a> should implement a class that inherits from <a href="Handler.html"><code>Psych::Handler</code></a> and define events that they can handle.</p>

<p><a href="Handler.html"><code>Psych::Handler</code></a> defines all events that <a href="Parser.html"><code>Psych::Parser</code></a> can possibly send to event handlers.</p>

<p>See <a href="Parser.html"><code>Psych::Parser</code></a> for more details</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="EVENTS">EVENTS
          <dd><p>Events that a <a href="Handler.html"><code>Handler</code></a> should respond to.</p>
          <dt id="OPTIONS">OPTIONS
          <dd><p>Default dumping options</p>
        </dl>
        </section>



                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-alias" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">alias</span><span
                                class="method-args">(anchor)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called when an alias is found to <code>anchor</code>.  <code>anchor</code> will be the name of the anchor found.</p>

<h3 id="method-i-alias-label-Example">Example<span><a href="#method-i-alias-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Here we have an example of an array that references itself in YAML:</p>

<pre>--- &amp;ponies
- first element
- *ponies</pre>

<p>&amp;ponies is the anchor, *ponies is the alias.  In this case, alias is called with “ponies”.</p>

                              <div class="method-source-code" id="alias-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 110</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">alias</span> <span class="ruby-identifier ruby-title">anchor</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-empty" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">empty</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called when an empty event happens. (Which, as far as I can tell, is never).</p>

                              <div class="method-source-code" id="empty-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 236</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">empty</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-end_document" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">end_document</span><span
                                class="method-args">(implicit)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called with the document ends.  <code>implicit</code> is a boolean value indicating whether or not the document has an implicit ending.</p>

<h3 id="method-i-end_document-label-Example">Example<span><a href="#method-i-end_document-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Given the following YAML:</p>

<pre>---
  hello world</pre>

<p><code>implicit</code> will be true.  Given this YAML:</p>

<pre>---
  hello world
...</pre>

<p><code>implicit</code> will be false.</p>

                              <div class="method-source-code" id="end_document-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 93</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">end_document</span> <span class="ruby-identifier">implicit</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-end_mapping" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">end_mapping</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called when a map ends</p>

                              <div class="method-source-code" id="end_mapping-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 230</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">end_mapping</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-end_sequence" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">end_sequence</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called when a sequence ends.</p>

                              <div class="method-source-code" id="end_sequence-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 191</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">end_sequence</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-end_stream" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">end_stream</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called when the YAML stream ends</p>

                              <div class="method-source-code" id="end_stream-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 241</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">end_stream</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-event_location" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">event_location</span><span
                                class="method-args">(start_line, start_column, end_line, end_column)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called before each event with line/column information.</p>

                              <div class="method-source-code" id="event_location-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 246</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">event_location</span>(<span class="ruby-identifier">start_line</span>, <span class="ruby-identifier">start_column</span>, <span class="ruby-identifier">end_line</span>, <span class="ruby-identifier">end_column</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-scalar" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">scalar</span><span
                                class="method-args">(value, anchor, tag, plain, quoted, style)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called when a scalar <code>value</code> is found.  The scalar may have an <code>anchor</code>, a <code>tag</code>, be implicitly <code>plain</code> or implicitly <code>quoted</code></p>

<p><code>value</code> is the string value of the scalar <code>anchor</code> is an associated anchor or nil <code>tag</code> is an associated tag or nil <code>plain</code> is a boolean value <code>quoted</code> is a boolean value <code>style</code> is an integer indicating the string style</p>

<p>See the constants in <a href="Nodes/Scalar.html"><code>Psych::Nodes::Scalar</code></a> for the possible values of <code>style</code></p>

<h3 id="method-i-scalar-label-Example">Example<span><a href="#method-i-scalar-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Here is a YAML document that exercises most of the possible ways this method can be called:</p>

<pre>---
- !str &quot;foo&quot;
- &amp;anchor fun
- many
  lines
- |
  many
  newlines</pre>

<p>The above YAML document contains a list with four strings.  Here are the parameters sent to this method in the same order:</p>

<pre class="ruby"><span class="ruby-comment"># value               anchor    tag     plain   quoted  style</span>
[<span class="ruby-string">&quot;foo&quot;</span>,               <span class="ruby-keyword">nil</span>,      <span class="ruby-string">&quot;!str&quot;</span>, <span class="ruby-keyword">false</span>,  <span class="ruby-keyword">false</span>,  <span class="ruby-value">3</span>    ]
[<span class="ruby-string">&quot;fun&quot;</span>,               <span class="ruby-string">&quot;anchor&quot;</span>, <span class="ruby-keyword">nil</span>,    <span class="ruby-keyword">true</span>,   <span class="ruby-keyword">false</span>,  <span class="ruby-value">1</span>    ]
[<span class="ruby-string">&quot;many lines&quot;</span>,        <span class="ruby-keyword">nil</span>,      <span class="ruby-keyword">nil</span>,    <span class="ruby-keyword">true</span>,   <span class="ruby-keyword">false</span>,  <span class="ruby-value">1</span>    ]
[<span class="ruby-string">&quot;many\nnewlines\n&quot;</span>,  <span class="ruby-keyword">nil</span>,      <span class="ruby-keyword">nil</span>,    <span class="ruby-keyword">false</span>,  <span class="ruby-keyword">true</span>,   <span class="ruby-value">4</span>    ]
</pre>

                              <div class="method-source-code" id="scalar-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 150</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">scalar</span> <span class="ruby-identifier">value</span>, <span class="ruby-identifier">anchor</span>, <span class="ruby-identifier">tag</span>, <span class="ruby-identifier">plain</span>, <span class="ruby-identifier">quoted</span>, <span class="ruby-identifier">style</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-start_document" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">start_document</span><span
                                class="method-args">(version, tag_directives, implicit)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called when the document starts with the declared <code>version</code>, <code>tag_directives</code>, if the document is <code>implicit</code>.</p>

<p><code>version</code> will be an array of integers indicating the YAML version being dealt with, <code>tag_directives</code> is a list of tuples indicating the prefix and suffix of each tag, and <code>implicit</code> is a boolean indicating whether the document is started implicitly.</p>

<h3 id="method-i-start_document-label-Example">Example<span><a href="#method-i-start_document-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Given the following YAML:</p>

<pre>%YAML 1.1
%TAG ! tag:tenderlovemaking.com,2009:
--- !squee</pre>

<p>The parameters for <a href="Handler.html#method-i-start_document"><code>start_document</code></a> must be this:</p>

<pre class="ruby"><span class="ruby-identifier">version</span>         <span class="ruby-comment"># =&gt; [1, 1]</span>
<span class="ruby-identifier">tag_directives</span>  <span class="ruby-comment"># =&gt; [[&quot;!&quot;, &quot;tag:tenderlovemaking.com,2009:&quot;]]</span>
<span class="ruby-identifier">implicit</span>        <span class="ruby-comment"># =&gt; false</span>
</pre>

                              <div class="method-source-code" id="start_document-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 72</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">start_document</span> <span class="ruby-identifier">version</span>, <span class="ruby-identifier">tag_directives</span>, <span class="ruby-identifier">implicit</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-start_mapping" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">start_mapping</span><span
                                class="method-args">(anchor, tag, implicit, style)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called when a map starts.</p>

<p><code>anchor</code> is the anchor associated with the map or <code>nil</code>. <code>tag</code> is the tag associated with the map or <code>nil</code>. <code>implicit</code> is a boolean indicating whether or not the map was implicitly started. <code>style</code> is an integer indicating the mapping style.</p>

<p>See the constants in <a href="Nodes/Mapping.html"><code>Psych::Nodes::Mapping</code></a> for the possible values of <code>style</code>.</p>

<h3 id="method-i-start_mapping-label-Example">Example<span><a href="#method-i-start_mapping-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Here is a YAML document that exercises most of the possible ways this method can be called:</p>

<pre>---
k: !!map { hello: world }
v: &amp;pewpew
  hello: world</pre>

<p>The above YAML document consists of three maps, an outer map that contains two inner maps.  Below is a matrix of the parameters sent in order to represent these three maps:</p>

<pre class="ruby"><span class="ruby-comment"># anchor    tag                       implicit  style</span>
[<span class="ruby-keyword">nil</span>,       <span class="ruby-keyword">nil</span>,                      <span class="ruby-keyword">true</span>,     <span class="ruby-value">1</span>     ]
[<span class="ruby-keyword">nil</span>,       <span class="ruby-string">&quot;tag:yaml.org,2002:map&quot;</span>,  <span class="ruby-keyword">false</span>,    <span class="ruby-value">2</span>     ]
[<span class="ruby-string">&quot;pewpew&quot;</span>,  <span class="ruby-keyword">nil</span>,                      <span class="ruby-keyword">true</span>,     <span class="ruby-value">1</span>     ]
</pre>

                              <div class="method-source-code" id="start_mapping-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 225</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">start_mapping</span> <span class="ruby-identifier">anchor</span>, <span class="ruby-identifier">tag</span>, <span class="ruby-identifier">implicit</span>, <span class="ruby-identifier">style</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-start_sequence" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">start_sequence</span><span
                                class="method-args">(anchor, tag, implicit, style)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called when a sequence is started.</p>

<p><code>anchor</code> is the anchor associated with the sequence or nil. <code>tag</code> is the tag associated with the sequence or nil. <code>implicit</code> a boolean indicating whether or not the sequence was implicitly started. <code>style</code> is an integer indicating the list style.</p>

<p>See the constants in <a href="Nodes/Sequence.html"><code>Psych::Nodes::Sequence</code></a> for the possible values of <code>style</code>.</p>

<h3 id="method-i-start_sequence-label-Example">Example<span><a href="#method-i-start_sequence-label-Example">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Here is a YAML document that exercises most of the possible ways this method can be called:</p>

<pre>---
- !!seq [
  a
]
- &amp;pewpew
  - b</pre>

<p>The above YAML document consists of three lists, an outer list that contains two inner lists.  Here is a matrix of the parameters sent to represent these lists:</p>

<pre class="ruby"><span class="ruby-comment"># anchor    tag                       implicit  style</span>
[<span class="ruby-keyword">nil</span>,       <span class="ruby-keyword">nil</span>,                      <span class="ruby-keyword">true</span>,     <span class="ruby-value">1</span>     ]
[<span class="ruby-keyword">nil</span>,       <span class="ruby-string">&quot;tag:yaml.org,2002:seq&quot;</span>,  <span class="ruby-keyword">false</span>,    <span class="ruby-value">2</span>     ]
[<span class="ruby-string">&quot;pewpew&quot;</span>,  <span class="ruby-keyword">nil</span>,                      <span class="ruby-keyword">true</span>,     <span class="ruby-value">1</span>     ]
</pre>

                              <div class="method-source-code" id="start_sequence-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 186</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">start_sequence</span> <span class="ruby-identifier">anchor</span>, <span class="ruby-identifier">tag</span>, <span class="ruby-identifier">implicit</span>, <span class="ruby-identifier">style</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-start_stream" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">start_stream</span><span
                                class="method-args">(encoding)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Called with <code>encoding</code> when the YAML stream starts.  This method is called once per stream.  A stream may contain multiple documents.</p>

<p>See the constants in <a href="Parser.html"><code>Psych::Parser</code></a> for the possible values of <code>encoding</code>.</p>

                              <div class="method-source-code" id="start_stream-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 47</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">start_stream</span> <span class="ruby-identifier">encoding</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-streaming-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">streaming?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Is this handler a streaming handler?</p>

                              <div class="method-source-code" id="streaming-3F-source">
            <pre><span class="ruby-comment"># File psych/lib/psych/handler.rb, line 251</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">streaming?</span>
  <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

